home *** CD-ROM | disk | FTP | other *** search
- #!/usr/bin/python
-
- import os
- import sys
- import gettext
- import locale
-
- from softwareproperties.SoftwareProperties import SoftwareProperties
- from optparse import OptionParser
- from gettext import gettext as _
-
- if __name__ == "__main__":
- locale.setlocale(locale.LC_ALL, "")
- parser = OptionParser()
- (options, args) = parser.parse_args()
-
- if os.geteuid() != 0:
- print _("Error: must run as root")
- sys.exit(1)
-
- if (len(args) != 1):
- print _("Error: need a repository as argument")
- sys.exit(1)
-
- # force new ppa file to be 644 (LP: #399709)
- os.umask(0022)
-
- sp = SoftwareProperties(options)
- line = args[0]
- if not sp.add_source_from_line(line):
- print _("Error: '%s' invalid" % line)
- sys.exit(1)
- sp.sourceslist.save()
-